<?php
include(getabspath("include/brcs_settings.php"));

function DisplayMasterTableInfo_brcs($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="brcs";

//$strSQL = "SELECT  id,  bank_id,  account_id,  ra_id,  signature,  designation,  office_address,  residential_address,  place,  brc_date,  ref_id,  \"\" AS bank_address,  \"\" AS account_address,  \"\" AS ra_address  FROM brcs  ";

$sqlHead="SELECT id,  bank_id,  account_id,  ra_id,  signature,  designation,  office_address,  residential_address,  place,  brc_date,  ref_id,  \"\" AS bank_address,  \"\" AS account_address,  \"\" AS ra_address";
$sqlFrom="FROM brcs";
$sqlWhere="";
$sqlTail="";

$where="";

if($detailtable=="brc_items")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);

	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	bank_id - 
			$value="";
				$value=DisplayLookupWizard("bank_id",$data["bank_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("bank_id_mastervalue",$value);

//	account_id - 
			$value="";
				$value=DisplayLookupWizard("account_id",$data["account_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("account_id_mastervalue",$value);

//	ra_id - 
			$value="";
				$value=DisplayLookupWizard("ra_id",$data["ra_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("ra_id_mastervalue",$value);

//	signature - 
			$value="";
				$value = ProcessLargeText(GetData($data,"signature", ""),"field=signature".$keylink,"",MODE_PRINT);
			$xt->assign("signature_mastervalue",$value);

//	designation - 
			$value="";
				$value = ProcessLargeText(GetData($data,"designation", ""),"field=designation".$keylink,"",MODE_PRINT);
			$xt->assign("designation_mastervalue",$value);

//	office_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"office_address", ""),"field=office%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("office_address_mastervalue",$value);

//	residential_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"residential_address", ""),"field=residential%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("residential_address_mastervalue",$value);

//	place - 
			$value="";
				$value=DisplayLookupWizard("place",$data["place"],$data,$keylink,MODE_PRINT);
			$xt->assign("place_mastervalue",$value);

//	brc_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"brc_date", "Short Date"),"field=brc%5Fdate".$keylink,"",MODE_PRINT);
			$xt->assign("brc_date_mastervalue",$value);

//	ref_id - 
			$value="";
				$value=DisplayLookupWizard("ref_id",$data["ref_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("ref_id_mastervalue",$value);

//	bank_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"bank_address", ""),"field=bank%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("bank_address_mastervalue",$value);

//	account_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"account_address", ""),"field=account%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("account_address_mastervalue",$value);

//	ra_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"ra_address", ""),"field=ra%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("ra_address_mastervalue",$value);
	$xt->display("brcs_masterprint.htm");
	$strTableName=$oldTableName;

}

?>